#include "stdio.h"

int main()
{
    int ch = 1; //菜单选项
	char number[20]; //车牌
	DLNode table;
	table.next = NULL; //初始化
	DLNode *tail = NULL; //尾指针记录，方便二次继续插入
	int num = 0; //入库车辆数量统计
	while(ch != 0)
	{
	    printf("-------------------------------------------------------------------------------\n");
	    printf("欢迎使用停车管理系统！车库总容量为 %d\n",MAX);
	    printf("停车请按 1, 查看入库车辆请按 2, 出库请按 3, 查询车库详情请按 4, 查询车辆请按 5\n");
	    printf("退出请按 0\n");
	    printf("停车1秒 %d 块钱，童叟无欺，谢谢合作\n",MONEY);
	    printf("-------------------------------------------------------------------------------\n");

		scanf("%d", &ch);
		switch(ch)
		{
		    case 0:
			{
			    break;
			}
		    case 1:
			{
			    tail = insert(&table, tail, &num);
				printf("%d\n",num);
				break;
			}
			case 2:
			{
			    if(isEmpty(&table) == 0)
	            {
	                Printf(&table);
	            }
				getchar();
				getchar();
				break;
			}
			case 3:
			{   
			    if(isEmpty(&table) == 0)
				{
			        printf("请输入车牌号：\n");
				    scanf("%s",number);
			      tail =  Delete(&table, number, tail, &num);
				}
				getchar();
				getchar();
			    break;
			}
			case 4:
			{   
			    if(isEmpty(&table) == 0)
				{
			        Check(&table);
				}else
				{
				    printf("车库为空，放心入库！");
				}
				getchar();
				getchar();
			    break;
			}
			case 5:
			{   
			    if(isEmpty(&table) == 0)
				{
			        printf("请输入车牌号：\n");
				    scanf("%s",number);
			        CheckByNum(&table, number);
				}
				getchar();
				getchar();
			    break;
			}
			default :
			{
			    printf("没有该选项哦!\n");
				getchar();
				getchar();
				break;
			}

		}
	system("clear"); //清屏
	}

	return 0;
}
